<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>

</body>
<script>
	// 要求传入的参数是空数组、空对象、空字符串、0、undefined、null、空 map、空 set时，返回 true，否则返回 false
	function isEmpty(value){
		if (value === null || value === undefined) return true
		if (Array.isArray(value)) return value.length === 0
		if (typeof value === 'string' && value.length === 0) return true
		if (typeof value === 'number' && value === 0) return true
		if (value instanceof Map || value instanceof Set) return value.size === 0
		if (value instanceof Object && Object.keys(value).length === 0) return true
		return false
	}
	
	console.log(isEmpty([]),isEmpty([1]))
	console.log(isEmpty({}),isEmpty({a:1}))
	console.log(isEmpty(''),isEmpty('1234'))
	console.log(isEmpty(0),isEmpty(123),isEmpty(-12))
	console.log(isEmpty(undefined),isEmpty(null))
	const map1 = new Map()
	map1.set('a',123)
	const map2 = new Map()
	console.log(isEmpty(map2),isEmpty(map1))
	const set1 = new Set()
	const set2 = new Set([1,23,2])
	console.log(isEmpty(set1),isEmpty(set2))
</script>
</html>